package com.palm.hubo2o.ui;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.view.View;

import com.palm.hubo2o.ui.fragment.D3BD1Fragment;
import com.palm.hubo2o.ui.fragment.D3BD3Fragment;
import com.palm.hubo2o.ui.fragment.D3BD6Fragment;
import com.palm.hubo2o.ui.fragment.D3DirFragment;
import com.palm.hubo2o.ui.fragment.D3Z3DFragment;
import com.palm.hubo2o.ui.fragment.D3Z3FFragment;
import com.palm.hubo2o.ui.fragment.D3Z6Fragment;
import com.palm.hubo2o.ui.fragment.LotteryFragment;
import com.palm.hubo2o.util.EnumCode;


/**
 * Created by dest1 on 2015/10/15.
 */
public class D3LotteryActivity extends LotteryActivity {

    @NonNull
    @Override
    protected EnumCode.gameId gameId() {
        return EnumCode.gameId.D3;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        LotteryFragment d3Dir = new D3DirFragment();
        d3Dir.setTitle("直选");
        LotteryFragment d3Z3d = new D3Z3DFragment();
        d3Z3d.setTitle("组三单式");
        LotteryFragment d3Z3f = new D3Z3FFragment();
        d3Z3f.setTitle("组三复式");
        LotteryFragment d3Z6 = new D3Z6Fragment();
        d3Z6.setTitle("组六");
        LotteryFragment d3Bd1 = new D3BD1Fragment();
        d3Bd1.setTitle("包点单选");
        LotteryFragment d3Bd3 = new D3BD3Fragment();
        d3Bd3.setTitle("包点组三");
        LotteryFragment d3Bd6 = new D3BD6Fragment();
        d3Bd6.setTitle("包点组六");
        setFragments(d3Dir, d3Z3d, d3Z3f, d3Z6, d3Bd1, d3Bd3, d3Bd6);
        handleLimitPick(getIntent());
    }

    @Override
    protected void onNewIntent(Intent intent) {
        super.onNewIntent(intent);
        handleLimitPick(intent);
    }

    private void handleLimitPick(Intent intent) {
        EnumCode.PlayType playType = (EnumCode.PlayType) intent.getSerializableExtra(EnumCode.PlayType.class.getName());
        if (playType != null) {
            switch (playType) {
                case D3_ZX:
                    vp.setEnabled(false);
                    tab.getTabAt(0).select();
                    tab.setVisibility(View.GONE);
                    break;
                case D3_Z3DS:
                    vp.setEnabled(false);
                    tab.getTabAt(1).select();
                    tab.setVisibility(View.GONE);
                    break;
                case D3_Z3FS:
                    vp.setEnabled(false);
                    tab.getTabAt(2).select();
                    tab.setVisibility(View.GONE);
                    break;
                case D3_Z6:
                    vp.setEnabled(false);
                    tab.getTabAt(3).select();
                    tab.setVisibility(View.GONE);
                    break;
                case D3_DXBD:
                    vp.setEnabled(false);
                    tab.getTabAt(4).select();
                    tab.setVisibility(View.GONE);
                    break;
                default:
                    break;
            }
        }
    }
}
